package top.chukongxiang.monitorservice.tools.rtp;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * RTP负载数据格式
 * @author 楚孔响
 * @version 1.0
 * @date 2023/9/13 19:44
 */
public enum RtpPayload {

    /**
     * GB28181_PS流
     */
    PS
    ;

    interface PsPack {
        byte getValue();
    }

    @Getter
    @AllArgsConstructor
    enum PsHeaderPack implements PsPack {

        /**
         * PS包头
         */
        HEADER((byte)0xBA),

        /**
         * SystemHeader
         */
        SYSTEM_HEADER((byte)0xBB),

        /**
         * PSM
         */
        PROGRAM_STREAM_MAP((byte)0xBC),

        /**
         * 视频PES Header
         */
        VIDEO_PES_HEADER((byte) 0xE0),

        /**
         * 音频PESHeader
         */
        AUDIO_PES_HEADER((byte) 0xC0),
        ;

        private final byte value;


        public static PsHeaderPack getByValue(byte value) {
            for (PsHeaderPack psHeaderPack : values()) {
                if (value == psHeaderPack.value) {
                    return psHeaderPack;
                }
            }
            return null;
        }

    }

    @Getter
    @AllArgsConstructor
    enum PsPayloadPack implements PsPack {

        /**
         * 0x64 ps payload SPS
         */
        PAYLOAD_SPS((byte)0x67),

        /**
         * 0x68 ps payload PPS
         */
        PAYLOAD_PPS((byte)0x68),

        /**
         * 0x65 I帧
         */
        PAYLOAD_IDR((byte)0x65),

        /**
         * 0x61 P帧
         */
        PAYLOAD_P1((byte)0x61),

        /**
         * 0x41 P帧
         */
        PAYLOAD_P2((byte)0x41),
        ;

        private final byte value;
        public static PsPayloadPack getByValue(byte value) {
            for (PsPayloadPack psPayloadPack : values()) {
                if (value == psPayloadPack.value) {
                    return psPayloadPack;
                }
            }
            return null;
        }
    }
}
